<?php session_start(); 
include ("../function.php");
include "../dbconnect.php";
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>IQ TEST</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="<?php echo $base_url;?>css/bootstrap.css" media="screen">
    <link rel="stylesheet" href="<?php echo $base_url;?>css/bootswatch.min.css">
	<link rel="stylesheet" href="<?php echo $base_url;?>css/form_validation.css">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="<?php echo $base_url;?>js/html5shiv.js"></script>
      <script src="<?php echo $base_url;?>js/respond.min.js"></script>
    <![endif]-->
	<script src="<?php echo $base_url;?>js/jquery-1.10.2.min.js"></script>
	<script src="<?php echo $base_url;?>js/bootstrap.min.js"></script>
    <script src="<?php echo $base_url;?>js/bootswatch.js"></script>
  </head>
  <body>
<?php include ("../menu.php"); ?>
    <div class="container">  
      <!-- Forms
      ================================================== -->
      <div>
        <div class="row">
          <div class="col-lg-12">
            <div class="page-header">
              <h2 id="forms">ประวัติการทำแบบทดสอบ   </h2>
            </div>
          </div>
        </div>
        <div class="row">
            <div class="well bs-component">
            <div class="bs-component">
				<table class="table table-bordered table-striped table-hover ">
				
		            <?php 
		            $student_code = (isset($_SESSION['student_code']))?$_SESSION['student_code']:0;
		            $student_id = (isset($_SESSION['student_id']))?$_SESSION['student_id']:0;
		            
					if($student_id > 0)
					{
					?>
					
					<thead>
					<tr>
						<th>แบบทดสอบ</th>
						<th>คะแนน</th>
					</tr>
					</thead>
				<tbody>
				<?php
					//get excercise
					$sql = "SELECT * FROM excercise WHERE status=1";
					$result = mysql_query($sql, $link);
					mysql_query("SET NAMES UTF8");
					$numrows = mysql_num_rows($result);
					if($numrows > 0)
					{
						$str ="";
						while ($arr = mysql_fetch_array($result, MYSQL_ASSOC))
						{
							$title = $arr['title'];
							$id_excercise = $arr['id_excercise'];
							
							//times = 1
							$str .= '<tr>';
							$str .= '<td>'.$title.'</td>';
							$str .= '<td>'.get_score_by_excercise_and_student_id($student_id,$id_excercise,1).'</td>';
							$str .= '</tr>';
							
							//times = 2
							$str .= '<tr>';
							$str .= '<td>'.$title.' แบบสลับข้อ</td>';
							$str .= '<td>'.get_score_by_excercise_and_student_id($student_id,$id_excercise,2).'</td>';
							$str .= '</tr>';
							
							//$str .= '<tr><td></td><td></td></tr>';
							
						}
						echo $str;
					}
					?>
					
					</tbody>
					
					<?php
					}
					else
					{
						echo "กรุณณากรอก รหัสนักศึกษาก่อน";
					}
		            

					
		          
		            ?>	
		            
		</table>
			
      
            </div>
        </div>
      </div>
      <footer>
        <div class="row">
          <div class="col-lg-12">
            <ul class="list-unstyled">
              <li class="pull-right"><a href="#top">Back to top</a></li>
            </ul>
          </div>
        </div>
      </footer>
    </div>
  </body>
</html>
